// SETUP

#include endepisodegraphics_other.txt

// HELPER FUNCTIONS	

function signanimate(sign) {
	var s = sign.show("turn");
	//s.onComplete(function() { resume(); sign.show("loop"); });
	//pause();
	while(!s.completed) {
		// do nothing
	}
	sign.show("loop");
}

function spinthewheel(sign, wheel) {
  var s = sign.show("turn");
	//s.onComplete(function() { resume(); sign.show("loop"); });
	//pause();
	while(!s.completed) {
		// do nothing
	}
	sign.hide();
	
  wheel.x = 30;
  wheel.y = -30;
  play("spinthewheel");
	var s = wheel.show("spin1");
	//s.onComplete(function() { resume(); sign.show("loop"); });
	//pause();
	while(!s.completed) {
		// do nothing
	}
	wheel.hide();
}

// ACTORS

actor("Baby Squid", screenwidthmid + 400, 100, 0xfda8ff, LEFT, TOP, "chat_monster1");
actor("Warrior", 150, screenheight - 100, Col.LIGHTBLUE, LEFT, BOTTOM, "chat_warrior", "characters/warrior/charicon_warrior");

// INTRO

play("music_cutscene_lesscheery");

changebackground("intro_sign");

sign.y = -screenheight;
babysquid.y = -screenheight;
sign.show("loop");
babysquid.show("idle");

Actuate.tween(sign, 2, { y: 0 }).ease(Expo.easeOut);
Actuate.tween(babysquid, 2, { y: 0 }).ease(Expo.easeOut);

wait(0.5);

fadein();

wait(1.5);

babysquid.show("talking");
speak("Baby Squid", "Hi! Hi! It’s me again!");
babysquid.show("worriedtalking");
actor("Baby Squid", screenwidthmid + 200, 100, 0xfda8ff, LEFT, TOP, "chat_monster1");
speak("Baby Squid", "I’m on my second warning here so|let’s make sure I get this right...");
actor("Baby Squid", screenwidthmid, 100, 0xfda8ff, LEFT, TOP, "chat_monster1");
babysquid.show("talking");
actor("Baby Squid", screenwidthmid + 200, 100, 0xfda8ff, LEFT, TOP, "chat_monster1");
speak("Baby Squid", "I’m meant to say 'SPIN THE WHEEL|TO SEE IF YOU WIN...");
actor("Baby Squid", screenwidthmid + 100, 100, 0xfda8ff, LEFT, TOP, "chat_monster1");
speak("Baby Squid", "...and don’t say anything about it being rigged...");
speak("Baby Squid", "...and don’t read that last bit out loud'.");
speak("Baby Squid", "Does that sound right? I hope so!");
actor("Baby Squid", screenwidthmid + 300, 100, 0xfda8ff, LEFT, TOP, "chat_monster1");
speak("Baby Squid", "I love being able to see you whenever|you win an episode!");
babysquid.show("idle");

babysquid.hide();

spinthewheel(sign, wheel);

signanimate(sign);

babysquid.show("talking");
actor("Baby Squid", screenwidthmid + 300, 100, 0xfda8ff, LEFT, TOP, "chat_monster1");
speak("Baby Squid", "Okay now I’m meant to say 'you lose|but sound sympathetic'. Right!");
babysquid.show("idle");

gamecompletefromcutscene();
